/**
 *匿名方式创建子对象
 */
public class ThreadDemo7 {
    public static void main(String[] args) {
        //创建线程并初始化
        Thread thread=new Thread(){
            @Override
            public void run(){
                Thread t=Thread.currentThread();
                System.out.println("任务执行:"+t.getName());
            }
        };
        //执行线程
        thread.start();
    }
}
